package com.example.interceptor.demos.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2023-12-04
 * Time:20:18
 * Text：拦截规则
 */
@Configuration
public class AppConfig implements WebMvcConfigurer {

    @Autowired
    private UserInterceptor userInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//       registry.addInterceptor(userInterceptor)
//               .addPathPatterns("/**")     //设置拦截模板
//               .excludePathPatterns("/user/reg")  //放开权限
//               .excludePathPatterns("/user/login")
//      ;
    }

//    @Override
//    public void configurePathMatch(PathMatchConfigurer configurer) {
//        configurer.addPathPrefix("api",c->true);   //请求地址添加一个前缀
//    }
}
